package com.ironone.mediaplayerdemo;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import com.ironone.mediaplayerdemo2.R;

public class Frag1 extends Fragment {

	static Button btn1;
	Button btn2;
	Button drag_btn;
	FrameLayout fragContainer;
	ViewPager viewPager;
	View view;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// Inflate the layout for this fragment
		fragContainer = (FrameLayout) getActivity().findViewById(R.id.fragContainer);
		
		view = inflater.inflate(R.layout.frag_one, container, false);
		drag_btn = (Button) view.findViewById(R.id.dragicon);
		btn1 = (Button) view.findViewById(R.id.menu_button1);
		btn2 = (Button) view.findViewById(R.id.menu_button2);

		drag_btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
				drag_btn.setClickable(false);
			    new Handler().postDelayed(new Runnable() {

			        @Override
			        public void run() {
			        	drag_btn.setClickable(true);
			        }
			    }, 1000);
				
				// Create new fragment and transaction
				Frag2 newFragment = new Frag2();
				FragmentTransaction transaction = getFragmentManager().beginTransaction();
				transaction.setCustomAnimations(R.anim.slide_right_to_middle, 0);
				// Replace whatever is in the fragment_container view with this fragment,
				// and add the transaction to the back stack
				transaction.add(R.id.fragContainer, newFragment);
				//transaction.addToBackStack(null);

				// Commit the transaction
				transaction.commit();
			}
		});
		
		//menu item 1 click
		btn1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
			}
		});

		btn2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				
			}
		});
		return view;
	}	
	
}
